package com.ag.dgm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;


import com.ag.bean.TbPlanType;
import com.ag.common.AgException;
import com.ag.common.IDServiceImpl;
import com.ag.common.IDUtil;
import com.ag.dgm.dao.TbPlanTypeDAO;
import com.ag.dgm.service.PlanTypeService;

@Service("planTypeService")
public class PlanTypeServiceImpl implements PlanTypeService {
	@Resource(name="DGMTbPlanTypeDAO")
	private TbPlanTypeDAO tbPlanTypeDAO;
	@Resource(name="iDServiceImpl")
	private IDServiceImpl idService;
	

	@Override
	public void add(TbPlanType tbPlanType) {
		String IDs = null;
		try {
			IDs = idService.findTablePK(IDUtil.TB_PLAN_TYPE);
		} catch (AgException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tbPlanType.setPtId(IDs);
		tbPlanTypeDAO.save(tbPlanType);
	}
	
	public void delete(TbPlanType ptr){
		TbPlanType tbPlanType = tbPlanTypeDAO.findById(ptr.getPtId());
		tbPlanTypeDAO.delete(tbPlanType);
	}

	@Override
	public void modify(TbPlanType tbPlanType) {
		tbPlanTypeDAO.attachDirty(tbPlanType);		
	}



	@Override
	public List<TbPlanType> find() {		
		return tbPlanTypeDAO.findAll();
	}

}
